<section class="section {page->class}">
	<h2 class="hide">{page->title}</h2>
	
	<script>
		$(function() {
			$("#{module}_add").validate({
				submitHandler : function(form) {
				
					// ajax로 등록후 list 페이지 새로 고침
					$.ajax({
						 url : form.action
						,data : $(form).serialize()
						,success:function(data){
							if(data.code == mesg.success) {
								alert(data.menu_refresh_url);
								if(data.menu_refresh_url) {
									$("aside#left menu").load(data.menu_refresh_url);
								}
								
								sagapo.article_refresh(data.return_url);
								
								// 리스트 페이지에서 변경된 값 바꿔주기
								$(".name_{result->ba_id}").text($("#{module}_name").val());
							} else {
								alert(data.msg);
							}
							
							return false;
						}
					});
					
				}
			});
			
			// checkbox, radio 선택..
			$("input:radio[name='{module}_category'][value='{result->ba_category}']").attr("checked","checked");
			$("input:radio[name='{module}_footlist'][value='{result->ba_footlist}']").attr("checked","checked");
			$("input:radio[name='{module}_attach'][value='{result->ba_attach}']").attr("checked","checked");
			$("#{module}_attach > option[value='{result->ba_attache}']").attr("selected", "selected");
			$("#{module}_skin > option[value='{result->ba_skin}']").attr("selected", "selected");
			
			{? result->menu}
			$("input:checkbox[name='{module}_menu'][value='1']").attr("checked","checked");
			{/}
			
			
			// 메뉴 등록 checkbox 선택시
			$("#{module}_menu").click(function() {
				if($(this).is(":checked")) {
					$(".menu_icon").removeClass("hide");
				} else {
					$(".menu_icon").addClass("hide");
				}
			});
			
			
			// 반드시 id값으로 설정해줘야됨.
			// class로 하면 dialog가 제대로 열리지 않음.
			$("#menu_iconset").dialog({
				resizable	: false,
				modal		: true,
				width		: 500,
				minWidth	: 500,
				height		: 500,
				autoOpen	: false,
				title		: '아이콘 선택'
				
			});
			
			// 메뉴 아이콘 선택 창 표시
			$(".menu_icon button.menu_icon_select").click(function() {
				$("#menu_iconset").dialog('open');	
				
				return false;
			});
			
			
			// 아이콘 선택시..
			$("#menu_iconset .iconset .icon").click(function() {
				
				$(".menu_icon .select_icon").html($(this).clone());
				
				$("#{module}_icon").val($(this).attr("alt"));
				$("#menu_iconset").dialog('close');
				return false;
			});
		});
	</script>
	<form name="{module}_add" id="{module}_add" method="post" action="{action}/doModify">
		<input type="hidden" name="{module}_bseq" value="{result->ba_seq}" />
		<input type="hidden" name="{module}_baid" value="{result->ba_id}" />
		<table class="table">
			<caption>
				{page->title}
			</caption>
			<colgroup>
				<col class="add" />
				<col />
			</colgroup>
			<tbody>
				<tr>
					<th scope="row" class="txt_right br">게시판 아이디</th>
					<td>
						{result->ba_id}
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_name">게시판 명</label></th>
					<td><input type="text" name="{module}_name" id="{module}_name" class="width_90 required" placeholder="게시판 명" value="{result->ba_name}" /></td>
				</tr>
				<tr class="odd">
					<th scope="row" class="txt_right br"><label for="{module}_skin">스킨</label></th>
					<td>
						<select name="{module}_skin" id="{module}_skin">
							{@ skin}
							<option value="{.value_}">{.value_}</option>
							{/}
						</select>
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_menu">메뉴등록</label></th>
					<td>
						<input type="checkbox" name="{module}_menu" id="{module}_menu" value="1" />
						<label for="{module}_menu">메뉴등록</label>
					</td>
				</tr>
				<tr class="menu_icon {? !result->menu}hide{/}">
					<th scope="row" class="txt_right br">아이콘 선택</th>
					<td>
						<div class="select_icon">
							{? result->menu}
								<img src="{CFG->PATH->IMAGE}/iconset/{result->menu->mn_icon}" alt="{result->menu->mn_icon}" title="{result->menu->mn_icon}" class="icon" />
							{/}
						</div>
						<button type="button" class="menu_icon_select">아이콘 선택</button>
						<input type="hidden" name="{module}_icon" id="{module}_icon" value="{result->menu->mn_icon}" />
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_category_on">카테고리</label></th>
					<td>
						<input type="radio" name="{module}_category" id="{module}_category_on" value="1" checked="checked" />
						<label for="{module}_category_on">사용</label>
						&nbsp;&nbsp;
						<input type="radio" name="{module}_category" id="{module}_category_off" value="0" />
						<label for="{module}_category_off">미사용</label>
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_footlist_on">하단리스트</label></th>
					<td>
						<input type="radio" name="{module}_footlist" id="{module}_footlist_on" value="1" checked="checked" />
						<label for="{module}_footlist_on">사용</label>
						&nbsp;&nbsp;
						<input type="radio" name="{module}_footlist" id="{module}_footlist_off" value="0" />
						<label for="{module}_footlist_off">미사용</label>
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_newicontime">새글강조시간</label></th>
					<td>
						<input type="number" name="{module}_newicontime" id="{module}_newicontime" class="width_30px required"  max="168" min="1" value="{result->ba_newicontime}" />
						시간 단위로 입력해주세요.
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_attach_on">첨부파일</label></th>
					<td>
						<input type="radio" name="{module}_attach" id="{module}_attach_on" value="1" checked="checked" />
						<label for="{module}_attach_on">사용</label>
						&nbsp;&nbsp;
						<input type="radio" name="{module}_attach" id="{module}_attach_off" value="0" />
						<label for="{module}_attach_off">미사용</label>
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_listing">리스트 갯수</label></th>
					<td>
						<input type="number" name="{module}_listing" id="{module}_listing" class="width_30px required" max="30" min="5" value="{result->ba_listingnum}" />
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_paging">페이징 갯수</label></th>
					<td>
						<input type="number" name="{module}_paging" id="{module}_paging" class="width_30px required" max="25" min="5" value="{result->ba_pagingnum}" />
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_thumb_width">썸네일 가로</label></th>
					<td>
						<input type="number" name="{module}_thumb_width" id="{module}_thumb_width" class="width_50px required"  max="700" value="{result->ba_thumwidth}"/> px
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_thumb_height">썸네일 세로</label></th>
					<td>
						<input type="number" name="{module}_thumb_height" id="{module}_thumb_height" class="width_50px required"  max="700" value="{result->ba_thumwidth}" /> px
					</td>
				</tr>
			</tbody>
		</table>
		<div class="button_area">
			<button type="submit">전송</button>
		</div>
		<div id="menu_iconset">
			<ul class="iconset">
				{@ iconset}
				<li>
					<img src="{CFG->PATH->IMAGE}/iconset/{.value_->name}" alt="{.value_->name}" title="{.value_->name}" class="icon" />
				</li>
				{/}
			</ul>
		</div>
	</form>
</section>